<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>解构赋值</title>
</head>
<body>
<p>解构：把整体拆分成组件. 机器人的对象=>解构=>头+身体+肚子+四肢</p>
<script>
    // 传统的赋值
    var a = 1, b = 2, c = 3;
    console.log(a, b, c);

    // 数组的解构赋值 []
    var [x, y, z] = [7, 8, 9];
    console.log(x, y, z);

    // 对象的赋值
    var user = {name: "舒永畅", age: 18, address: "郑州"};
    // 传统的对象属性赋值
    var username = user.name;
    var userage = user.age;
    var useraddr = user.address;
    console.log(username,userage,useraddr);

    // ES6的对象解构赋值 {对象的属性}
    var {name,age,address} = user;
    var {address} = user; // var address = user.address
    console.log(name,age,address);

</script>
</body>
</html>